package com.chen.demoa.controller;


import com.chen.demoa.bean.Demo;
import com.chen.demoa.service.DemoService;
import io.seata.spring.annotation.GlobalTransactional;


import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/demo")
public class DemoController {


    @Autowired
    private DemoService demoService;

    @RequestMapping("/test")
    public void DemoTest(){

        List<Demo> list= null;
        try {
            list = demoService.findAll();


        } catch (Exception e) {
            log.error("问题===============："+e.getMessage());
            e.printStackTrace();
        }

        System.out.println(list);
    }
    @RequestMapping("/test1")
    @GlobalTransactional(rollbackFor = Exception.class)
    public void DemoTest1(){
        List<Demo> list=demoService.findAll1();
        System.out.println(list);
    }
    @RequestMapping("/test2")

    public void DemoTest2(){
        demoService.create();

    }
}
